description "Datadog Trace Agent"

start on started datadog-agent
stop on (runlevel [!2345] or stopping datadog-agent)

respawn
respawn limit 4 25
normal exit 0

# Logging to console from the agent is disabled since the agent already logs using file or
# syslog depending on its configuration. We make upstart log what the process still outputs in order
# to log panics/crashes to /var/log/upstart/datadog-agent.log
console log
env DD_LOG_TO_CONSOLE=false

setuid dd-agent

script
  exec <%= install_dir %>/embedded/bin/trace-agent --config <%= etc_dir %>/datadog.yaml --pid <%= install_dir %>/run/trace-agent.pid
end script

post-stop script
  rm -f <%= install_dir %>/run/trace-agent.pid
end script
